<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css">
    <link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id='link'>
</head>

<body style="overflow:hidden; padding:10px;">
    <form>
        <table class="formtable" style="width:580px;">

            <tbody>


                {if condition="$info.username neq ''"}
                {else /}
                <tr>
                    <td class="tlabel">用户名</td>
                    <td>
                        <input type="text" class="forminput inputstyle1" id="username" value="{$info.username}">
                    </td>
                </tr>
                <tr>
                    <td class="tlabel">密码</td>
                    <td>
                        <input type="text" class="forminput inputstyle1" id="password" value="">
                    </td>
                </tr>
                {/if}


                <tr>
                    <td class="tlabel">机构</td>
                    <td>
                        <select type="text" id="mid" class="select" v-model="checked">
                            <option value="">
                                请选择
                            </option>
                            <option v-for="item in list" :value='item.id'>
                                {{item.name}}
                            </option>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td class="tlabel">角色</td>
                    <td>
                        <select type="text" id="jiaoseid" class="select" v-model="checked">
                            <option value="">
                                请选择
                            </option>
                            <option v-for="item in list" :value='item.id'>
                                {{item.jiaosename}}
                            </option>
                        </select>
                    </td>
                </tr>



                <tr>
                    <td class="tlabel">状态</td>
                    <td>
                        <select type="text" id="state" class="select" required="required">

                            {if condition="$info.state eq 1"}
                            <option value="1" selected="selected"> 正常 </option>
                            <option value="-1"> 禁用 </option>
                            {elseif condition="$info.state eq -1"/}
                            <option value="1"> 正常 </option>
                            <option value="-1" selected="selected"> 禁用 </option>
                            {else /}
                            <option value="1"> 正常 </option>
                            <option value="-1"> 禁用 </option>
                            {/if}


                        </select>
                    </td>
                </tr>



            </tbody>

        </table>

        <div class="formbtn">
            <input type="button" value="保存" class="btnsave">
            <input type="button" value="取消" class="btncancel">
        </div>
        <input type="hidden" id="id" value="{$info.id}" />
    </form>


</body>
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/vue2.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script>
    var jiaoseid = "{$info.jiaoseid}";
    var mid = "{$info.mid}";

    var jiaoseid = new Vue({
        el: '#jiaoseid',
        data: {
            checked: jiaoseid,
            list: []
        },
        methods: {
            getdata: function () {
                var _self = this;//保存this的指向

                $.get('/Super/Jiaose/GetJiaoseList', function (data) {
                    _self.list = data;
                });
            }

        },
        created: function () {  //初始化事件里边去调用查询方法
            this.getdata();
        }
    });

    var mid = new Vue({
        el: '#mid',
        data: {
            checked: mid,
            list: []
        },
        methods: {
            getdata: function () {
                var _self = this;//保存this的指向

                $.get('/Super/Mechanism/GetMechanismList', function (data) {
                    _self.list = data;
                });
            }

        },
        created: function () {  //初始化事件里边去调用查询方法
            this.getdata();
        }
    });

    $(function () {
        $(".btnsave").click(function () {
            var id = $("#id").val();
            var username = $("#username").val();
            var password = $("#password").val();

            var state = $("#state").val();
            var jiaoseid = $("#jiaoseid").val();
            var mid = $("#mid").val();




            $.post("/Super/User/Add", {
                "id": id, "username": username, "password": password, "state": state,
                "jiaoseid": jiaoseid, "mid": mid
            }, function (data) {
                if (data.status == 200) {
                    var index = parent.layer.getFrameIndex(window.name);
                    window.parent.iframe.contentWindow.location.reload(true);
                    console.log(window.parent.iframe);
                    parent.layer.close(index);
                } else {
                    layer.msg(data.message);
                }
            });
        });
        $(".btncancel").click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
    });
    var quanxian = "{$info.quanxian}";
    var arrChk = $("input[name='quanxian']");
    $(arrChk).each(function () {

        if (quanxian.indexOf(this.value + ",") != -1) {

            $(this).attr('checked', 'checked');
        }
    });

</script>

</html>